package com.example.common.security.config;

import com.example.common.security.Interceptors.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2025-03-13
 * Time: 15:23
 */

@Configuration
// 将拦截器注册
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private TokenInterceptor tokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 将延长 token 拦截配置注册进来, 并添加拦截路径
        registry.addInterceptor(tokenInterceptor)
                .excludePathPatterns("/**/login")
                .excludePathPatterns("**/test/**")
                .addPathPatterns("/**");
    }
}
